package com.prosoft.library;

import java.util.Date;

import org.hibernate.Session;

import com.prosoft.user.DBUser;
import com.prosoft.util.HibernateUtil;

public class DAOService {

	public DBUser createDBUser(int id, String name, String createdBy) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		DBUser user = new DBUser();
		try {
			session.beginTransaction();

			user.setUserId(id);
			user.setUsername(name);
			user.setCreatedBy(createdBy);
			user.setCreatedDate(new Date());

			session.save(user);
			session.getTransaction().commit();

		} catch (Exception e) {
			e.printStackTrace();
		}
		return user;
	}

}
